package com.lzx.demo.bloodpressurehelper.fragment.home.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lzx.demo.bloodpressurehelper.R;
import com.lzx.demo.bloodpressurehelper.bean.CalendarBean;

/**
 * Created by admin on 2016/10/28.
 */
public class CalendarWeekAdapter extends BaseAdapter {
    private Context mContext;

    public CalendarWeekAdapter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return 7;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView==null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_calendar_week, parent, false);
            holder = new ViewHolder();
            holder.calendarWeekText = (TextView) convertView.findViewById(R.id.calendar_week_text);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        String weekText = CalendarBean.WEEKS[position];
        holder.calendarWeekText.setText(weekText);
        if(position==0||position==6) {
            holder.calendarWeekText.setTextColor(Color.parseColor("#F7602C"));
        }
        return convertView;
    }

    static class ViewHolder{
        TextView calendarWeekText;
    }
}
